package com.quasar.hpatient.view.adapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.quasar.hpatient.R;
import com.quasar.hpatient.model.medicalmodel.DoctorListBean;
import com.vise.log.ViseLog;


/**
 * author : 许建宏
 * Date: 2017/12/15 0015
 * View:
 */

public class ChoiceDoctorxAdapter extends BaseQuickAdapter<DoctorListBean, BaseViewHolder> {

    public ChoiceDoctorxAdapter() {
        super(R.layout.doctorx_item_layout);
    }

    @Override
    protected void convert(final BaseViewHolder helper, DoctorListBean item) {
        CheckBox cb_doctor=helper.getView(R.id.cb_doctor);
        if(item.getRealName()!=null){
            cb_doctor.setText(item.getRealName());
        }

        cb_doctor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // 通过这个方法，来监听当前的checkbox是否被选中
                if (isChecked) {
                    ViseLog.d("选中");
                    ChoiceDoctorxAdapter.this.getData().get(helper.getLayoutPosition()).setChoice(true);
                }else{
                    ViseLog.d("取消选中");
                    ChoiceDoctorxAdapter.this.getData().get(helper.getLayoutPosition()).setChoice(false);
                }
            }
        });

        if(ChoiceDoctorxAdapter.this.getData().get(helper.getLayoutPosition()).isChoice()){
            cb_doctor.setChecked(true);
        }else{
            cb_doctor.setChecked(false);
        }
    }
}
